import { request } from "../Request";

//隔热隔声紧固件管理
export function getFastenerRepositoryListApi(params) {
  let formData = new FormData();
  formData.append('file', params.raw);

  let url = `/fastenerLibrary/attributesImport`;
  let config = {
    headers: {"Content-Type": "multipart/formdata"}
  };
  return new Promise((resolve) => {
    request({
      url: url,
      method: 'POST',
      data: formData,
      config: config,
    }).then(res => {
      if (res.status === 200) {
        resolve(res);
      }
    })
  })
}

//通过零件编号获取当前零件的所有属性
export function getPartInfoByPartNumberApi(params){
  let url = `/fastenerLibrary/getAllPartInfoList`;
  let formData = new FormData();
  formData.append('PartNumber',params);
  return request({
    url: url,
    method: 'POST',
    data: formData
  });
}

//根据零件号获取重量
export function getFastenerWeightApi(params){
  let url = `/fastenerWeightLibrary/queryFastenerWeightLibraryList`;
  let formData = new FormData();
  formData.append('PartNumber',params.partNumber);

  return request({
    url: url,
    method: 'POST',
    data: formData
  });
}

export function getAllFastenerWeightInfoApi(){
  let url = `/fastenerWeightLibrary/getAllFastenerWeightInfoList`;

  return request({
    url: url,
    method: 'get'
  });
}
